﻿namespace CleanLite.DynamicApi
{
    /// <summary>
    /// 扩展方法
    /// </summary>
    internal static class DynamicExtensionMethods
    {
        /// <summary>
        /// 去除后缀
        /// </summary>
        /// <param name="str"></param>
        /// <param name="suffixes"></param>
        /// <returns></returns>
        public static string IgnoreSuffix(this string str, List<string> suffixes)
        {
            if (string.IsNullOrEmpty(str) || suffixes == null || suffixes.Count == 0)
                return str;

            foreach (var suffix in suffixes)
            {
                if (str.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))
                {
                    return str[..^suffix.Length];
                }
            }
            return str;
        }
    }
}